//
//  PrintTypeTableViewCell.m
//  ForestPack
//
//  Created by 郑洲 on 2018/7/18.
//  Copyright © 2018年 郑洲. All rights reserved.
//

#import "PrintTypeTableViewCell.h"

@interface PrintTypeTableViewCell ()

@property (nonatomic, strong) UILabel *typeNameLabel;
@property (nonatomic, strong) UIView *detailBg;
@property (nonatomic, strong) UIImageView *typeImage;
@property (nonatomic, strong) UILabel *detailLabel;
@property (nonatomic, strong) UIImageView *selectImage;

@end

@implementation PrintTypeTableViewCell

+ (PrintTypeTableViewCell *)cellWithTableView:(UITableView *)tableView andIndexPath:(NSIndexPath *)indexPath{
    static NSString *cellID = @"PrintTypeTableViewCell";
    PrintTypeTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[PrintTypeTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.backgroundColor = [UIColor whiteColor];
        [cell createSubView];
    }
    
    return cell;
}

- (void)createSubView {
    self.typeNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(13), 0, ScreenX375(200), ScreenX375(45))];
    self.typeNameLabel.textColor = REXADECIMALCOLOR(@"#333333");
    self.typeNameLabel.font = Kfont(14);
    [self addSubview:self.typeNameLabel];
    
    self.detailBg = [[UIView alloc] initWithFrame:CGRectMake(ScreenX375(13), ScreenX375(45), SCREEN_WIDTH - ScreenX375(26), ScreenX375(113))];
    self.detailBg.backgroundColor = [UIColor whiteColor];
    self.detailBg.layer.cornerRadius = 3;
    self.detailBg.clipsToBounds = YES;
    self.detailBg.layer.borderWidth = 1;
    [self addSubview:self.detailBg];
    
    self.typeImage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, ScreenX375(150), ScreenX375(113))];
    [self.detailBg addSubview:self.typeImage];
    
    self.detailLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(166), ScreenX375(16), ScreenX375(160), ScreenX375(55))];
    self.detailLabel.font = Kfont(12);
    self.detailLabel.numberOfLines = 0;
    [self.detailBg addSubview:self.detailLabel];
    
    self.selectImage = [[UIImageView alloc] initWithFrame:CGRectMake(ScreenX375(321.5), ScreenX375(85.5), ScreenX375(27.5), ScreenX375(27.5))];
    self.selectImage.image = [UIImage imageNamed:@"矩形2"];
    self.selectImage.hidden = YES;
    [self.detailBg addSubview:self.selectImage];
    
    UIImageView *selectImageC = [[UIImageView alloc] initWithFrame:CGRectMake(ScreenX375(11.5), ScreenX375(14.5), ScreenX375(14), ScreenX375(9))];
    selectImageC.image = [UIImage imageNamed:@"勾选白色"];
    [self.selectImage addSubview:selectImageC];
}

- (void)setStatus:(BOOL)isSelect andModel:(PrintTypeModel *)model{
    if (isSelect) {
        self.selectImage.hidden = NO;
        self.detailLabel.textColor = ThemeColor;
        self.detailBg.layer.borderColor = ThemeColor.CGColor;
    }else {
        self.selectImage.hidden = YES;
        self.detailLabel.textColor = REXADECIMALCOLOR(@"#999999");
        self.detailBg.layer.borderColor = REXADECIMALCOLOR(@"#dcdcdc").CGColor;
    }
    self.typeNameLabel.text = model.name;
    [self.typeImage sd_setImageWithURL:[NSURL URLWithString:model.image] placeholderImage:nil options:SDWebImageRetryFailed];
    self.detailLabel.text = model.descriptionStr;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end

@implementation PrintTypeModel


@end
